//
//  TodayNewsTopView.m
//  口袋
//
//  Created by dllo on 15/5/22.
//  Copyright (c) 2015年 口袋. All rights reserved.
//

#import "TodayNewsTopView.h"
#import "DKNightVersion.h"

#define W [UIScreen mainScreen].bounds.size.width
#define H [UIScreen mainScreen].bounds.size.height
@implementation TodayNewsTopView

- (void)dealloc
{
    [_imageView release];
    [_titleLabel release];
    [_commentButton release];
    [_contentLabel release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createImageView];
        [self createLabel];
        
    }
    return self;
}

- (void)createImageView
{
    self.imageView = [[UIImageView alloc]initWithFrame:CGRectMake(W*0.03, W*0.03, W - (W*0.03)*2, (W - 40)/1.8)];
    //[self.imageView setBackgroundColor:[UIColor lightGrayColor]];
    [self addSubview:self.imageView];
    [self.imageView release];
    
    UIImageView *topicon = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 90, 90)];
    [topicon setImage:[UIImage imageNamed:@"top1.png"]];
    [self addSubview:topicon];
    [topicon release];
}
- (void)createLabel
{
    self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(W*0.03, self.imageView.frame.size.height+W*0.03*2 , W - (W*0.03)*2, (W - (W*0.03)*2)/12)];
   // [self.titleLabel setBackgroundColor:[UIColor orangeColor]];
    self.titleLabel.font = [UIFont systemFontOfSize:18];
    self.titleLabel.nightTextColor = [UIColor lightGrayColor];
    [self addSubview:self.titleLabel];
    [self.titleLabel release];
    
    self.contentLabel = [[UILabel alloc]initWithFrame:CGRectMake(W*0.03, self.titleLabel.frame.origin.y  + self.titleLabel.frame.size.height, self.titleLabel.frame.size.width, (W - W*0.03*2)/6)];
   // [self.contentLabel setBackgroundColor:[UIColor orangeColor]];
    self.contentLabel.textColor = [UIColor grayColor];
    self.contentLabel.font = [UIFont systemFontOfSize:15];
    self.contentLabel.numberOfLines = 0;
    [self addSubview:self.contentLabel];
    [self.contentLabel release];
    
    //CGRectMake(W*0.03, self.titleLabel.frame.origin.y + self.titleLabel.frame.size.height, W*0.03, W - (W*0.03)*2, (W - W*0.03*2)/17)];
    
    self.commentButton = [[UIButton alloc]initWithFrame:CGRectMake(0.7*W, H / 2.38, W * 0.3 - 0.03*W, 0.03 * H)];
    //UILabel *label = [UILabel alloc]initWithFrame:<#(CGRect)#>
    [self.commentButton setTitle:@"  跟帖数" forState:UIControlStateNormal];
    //    [self.commentButton.layer setMasksToBounds:YES];
    //    [self.commentButton.layer setCornerRadius:2];
    //    [self.commentButton setBackgroundColor:[UIColor grayColor]];
    //    [self.commentButton.layer setBorderWidth:0.3];
    
    self.commentButton.titleLabel.font = [UIFont systemFontOfSize:12];
    self.commentButton.titleLabel.textAlignment = 2;
    [self.commentButton setImage:[UIImage imageNamed:@"comment.png"] forState:UIControlStateNormal];
    [self.commentButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [self.commentButton setBackgroundColor:[UIColor whiteColor]];
    self.commentButton.nightBackgroundColor = UIColorFromRGB(0x343434);
    // [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    
    [self addSubview:self.commentButton];
    [self.commentButton release];
    
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    [(NSObject *)self.target performSelector:self.action withObject:self];
}
@end

